<template>
    <div class="bannerLL">
        <div class="bannerLL-card">
            <div class="bannerLL-head">
                <ButtonGroup style="float: right">
                    <Button type="primary" @click="$router.push({name:'banner-nocache'})"><Icon type="plus-round"></Icon> 新 增</Button>
                </ButtonGroup>
            </div>
            <i-table ref="tableCsv" height="730" stripe :columns="columns" :data="data"></i-table>
        </div>
        <Modal v-model="modal2" width="360">
            <p slot="header" style="color:#f60;text-align:center">
                <Icon type="ios-information-circle"></Icon>
                <a>删除</a>
            </p>
            <div style="text-align:center">
                <p>确定删除当前吗?</p>
            </div>
            <div slot="footer">
                <Button type="primary" size="large" long :loading="modal_loading" @click="del">删除</Button>
            </div>
        </Modal>
        <Modal title="查看图片" v-model="visible">
            <img :src="image" style="width: 100%">
        </Modal>
    </div>
</template>

<script>
    export default {
        name: "chongzhi",
        data(){
            return{
                modal2:false,
                visible: false,
                image: '',
                columns:[
                    {
                        title: '序号',
                        type: 'index',
                        width: 60,
                        align:"center",
                    },
                   /* {
                        title: '内容',
                        key: 'name',
                        align:"center",
                    },*/
                    {
                        title: '用户',
                        key: 'username',
                        align:"center",
                    },
                    {
                        title: '数量',
                        key: 'num',
                        align:"center",
                    },
                    {
                        title: '手续费',
                        key: 'fee',
                        align:"center",
                    },
                    {
                        title: '币种',
                        key: 'money_type_name',
                        align:"center",
                    },
                    {
                        title: '状态',
                        key: 'status',
                        align:"center",
                        render: (h, params) => {
                            if (params.row.status == 0) {
                                return '待审核'
                            }
                            else if (params.row.status == 1) {
                                return '已通过'
                            }
                            else if (params.row.status == 2) {
                                return '已拒绝'
                            }
                        }
                    },
                    {
                        title: '时间',
                        key: 'add_time',
                        align:"center",
                        render: (h, params) => {
                            return this.timeFormat(params.row.add_time)
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        align: 'center',
                        width:300,
                        render: (h, params) => {
                            if (params.row.status == 0){
                                return h('ButtonGroup', [
                                    h("Button", {
                                        props: {
                                            type: "primary"
                                        },
                                        on: {
                                            click: () => {
                                                this.tongguo(params.row.id)
                                            }
                                        }
                                    }, "通过"),
                                    h("Button", {
                                        props: {
                                            type: "error"
                                        },
                                        on: {
                                            click: () => {
                                                this.jujue(params.row.id)
                                            }
                                        }
                                    }, "拒绝"),
                                    /* h('Button', {
                                         props: {
                                             type: 'primary',
                                         },
                                         on: {
                                             click: () => {
                                                 this.$router.push({name:"banner-nocache",query:{id:params.row.id}})
                                             }
                                         }
                                     },"修改"),
                                     h('Button', {
                                         props: {
                                             type: 'primary',
                                         },
                                         on: {
                                             click: () => {
                                                 this.id=params.row.id
                                                 this.modal2=true
                                             }
                                         }
                                     },"删除"),*/
                                ]);
                            }
                        }
                    },
                ],
                data:[],
                id:"",
                modal_loading:false,
            }
        },
        activated(){
            this.getList()
        },
        methods:{
            //获取列表数据
            getList(){
                this.getJsonData("Recharge/getRechargeList")
                    .then((res)=>{
                        this.data=res.data
                    })
            },
            tongguo(id){
                this.getJsonData("Recharge/recharge_adopt", {
                    id: id,
                }, true)
                    .then((res) => {
                        this.getList()
                        this.$Message.success("已通过");
                    })
            },
            jujue(id){
                this.getJsonData("Recharge/recharge_refuse", {
                    id: id,
                }, true)
                    .then((res) => {
                        this.getList()
                        this.$Message.success("已拒绝");
                    })
            },
            del(){
                this.modal_loading=true
                this.getJsonData("table/delete_table",{id:this.id},true)
                    .then((res)=>{
                        this.modal_loading=false
                        this.modal2=false
                        this.$Message.success("删除成功")
                        this.getList()
                    })
                    .catch(()=>{
                        this.modal_loading=false
                    })
            }
        }
    }
</script>

<style scoped lang="less">
    @import "bannerLL";
</style>
